//
//  EmptyView.m
//  Patient
//
//  Created by lbh on 2021/6/16.
//  Copyright © 2021 hs. All rights reserved.
//

#import "EmptyView.h"

@implementation EmptyView

- (instancetype)initWithFrame:(CGRect)frame {
    
    self = [super initWithFrame:frame];
    if (self) {
        
        [self makeUI];
    }
    return self;
}

#pragma maek --Private
- (void)makeUI {
    
    [self addSubview:self.bEmptyBgView];
    [self.bEmptyBgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self.mas_centerX);
        make.centerY.mas_equalTo(self.mas_centerY).offset(-50);
    }];
    
    [self.bEmptyBgView addSubview:self.bEmptyImageView];
    [self.bEmptyImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(0);
        make.centerX.mas_equalTo(self.bEmptyBgView.mas_centerX);
    }];
    
    [self.bEmptyBgView addSubview:self.bEmptyLabel];
    [self.bEmptyLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.bEmptyImageView.mas_bottom).offset(12);
        make.centerX.mas_equalTo(self.bEmptyBgView.mas_centerX);
    }];
    
    [self.bEmptyBgView addSubview:self.bEmptyButton];
    [self.bEmptyButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.bEmptyLabel.mas_bottom).offset(10);
        make.centerX.mas_equalTo(self.bEmptyBgView.mas_centerX);
    }];
    self.bEmptyButton.hidden = YES;
}
- (void)updataBemptyLabel:(UIColor *)textColor withFont:(UIFont *)font{
    
    self.bEmptyLabel.textColor = textColor;
    self.bEmptyLabel.font = font;
}
- (void)configData:(NSString *)iconStr withTitleStr:(NSString *)title{
    
    self.bEmptyImageView.image = [UIImage imageNamed:iconStr];
    self.bEmptyLabel.text = title;
}
#pragma mark --Action
- (void)bEmptyBtnAction:(UIButton *)btn {
    
    if (self.reloadBtnBlock) {
        
        self.reloadBtnBlock();
    }
}

#pragma mark --Lazy
//空视图
- (UIView *)bEmptyBgView {
    
    if (!_bEmptyBgView) {
        
        _bEmptyBgView = [[UIView alloc]init];
        _bEmptyBgView.backgroundColor = [UIColor clearColor];
    }
    return _bEmptyBgView;
}
- (UIImageView *)bEmptyImageView {
    
    if (!_bEmptyImageView) {
        _bEmptyImageView = [[UIImageView alloc]init];
        _bEmptyImageView.image = [UIImage imageNamed:@"comEmpt"];
    }
    return _bEmptyImageView;
}
- (UILabel *)bEmptyLabel {
    if (!_bEmptyLabel) {
        _bEmptyLabel = [[UILabel alloc]init];
        _bEmptyLabel.text = @"No data found";
        _bEmptyLabel.textColor = [UIColor grayColor];
        _bEmptyLabel.font = [UIFont systemFontOfSize:14];
    }
    return _bEmptyLabel;
}

- (UIButton *)bEmptyButton {
    if (!_bEmptyButton) {
        _bEmptyButton = [UIButton buttonWithType:UIButtonTypeCustom];
        [_bEmptyButton setImage:[UIImage imageNamed:@"order_icon_phone"] forState:UIControlStateNormal];
        [_bEmptyButton setTitle:@" Reload " forState:UIControlStateNormal];
        [_bEmptyButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        _bEmptyButton.titleLabel.font = [UIFont systemFontOfSize:14];
        _bEmptyButton.hidden = YES;
        [_bEmptyButton addTarget:self action:@selector(bEmptyBtnAction:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _bEmptyButton;
}

@end
